Visually nothing happens. The actionPerformed()
method is called with a new Event
object,
but it changes nothing.
If you feel like some fun,
modify the code so that each click changes the background to a different color.
The pictures show the output of the program. The original frame is on the left. On the right is the frame after a button click.
The Java system automatically paints the frame when any of several things has happened:
However, a mere button click does not necessarily mean that a frame should be
repainted.
If it does, as it does in this program, call repaint()
in the actionPerformed()
method.
(Memory Test: ) What is the name of the method that receives
ActionEvent
s when a button is clicked?